﻿using System.Collections.Generic;
using DataModel.DataModelContext;

namespace DataModel.DataCenter
{
    /// <summary>
    /// Everyone Call Database Throwght Class Here.
    /// </summary>
    public static class GetDataCenter
    {
        private const string ConnectionString = @"isostore:/EnglishStudy.sdf";
        static readonly GetLesson GetLessons = new GetLesson();
        static readonly GetLoginInfo GetLoginInfos = new GetLoginInfo();
        /// <summary>
        /// Check Exits DB
        /// </summary>
        /// <returns></returns>
        public static bool CheckDatabaseExists()
        {
            using (var context = new EnglishStudyContext(ConnectionString))
            {
                if (context.DatabaseExists())
                {
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// Delete user login
        /// </summary>
        /// <param name="stt"></param>
         public static void DeleteUser(int stt)
         {
             GetLoginInfos.DeleteUser(stt);
         }
         /// <summary>
         /// Insert user login
         /// </summary>
         /// <param name="user"></param>
         public static void InsertUser(TblLoginInfo user)
         {
             GetLoginInfos.AddLoginInfo(user);
         }
        /// <summary>
        /// Update user login
        /// </summary>
        /// <param name="user"></param>
         public static void UpdatetUser(TblLoginInfo user)
         {
             GetLoginInfos.UpdateLoginInfo(user);
         }
        /// <summary>
        /// Get User Login
        /// </summary>
        /// <returns></returns>
        public static TblLoginInfo GetUserLogin()
        {
           return GetLoginInfos.LoginInfo();
        }
        /// <summary>
        /// Create new database
        /// </summary>
        public static void CreateDatabase()
        {
            using (var context = new EnglishStudyContext(ConnectionString))
            {
                if (!context.DatabaseExists())
                {
                    context.CreateDatabase();
                }
            }
        }
        /// <summary>
        /// Insert Lesson To Database
        /// </summary>
        /// <param name="lesson"></param>
        public static void InsertLesson(TblLesson lesson)
        {
            GetLessons.AddTblLesson(lesson);
        }
        public static void DeleteLesson(int stt)
        {
            GetLessons.DeleteLession(stt);
        }
    }
}
